package com.hnkywl.sts.action.jsgl;

import com.google.gson.Gson;
import com.hnkywl.sts.dao.jsgl.FpDao;
import com.hnkywl.sts.dao.jsgl.XsjsdmxDao;
import com.hnkywl.sts.entity.cggl.Jsd;
import com.hnkywl.sts.entity.sys.Gncz;
import com.hnkywl.sts.service.jsgl.FpcxService;
import com.hnkywl.sts.service.jsgl.XsjsdService;
import com.hnkywl.sts.service.sys.GnczService;
import com.hnkywl.sts.service.sys.YgService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by HL on 2015/9/22.
 */
@Namespace("/jsgl/fpcx")
public class FpcxAction extends SimpleActionSupport {
    private FpcxService fpcxService;

    private XsjsdService xsjsdService;
    private Long fpcgjsdId;
    private Long fpwljsdId;
    private Long fpxsjsdId;
    private Jsd cgjsdFp;
    private Jsd wljsdFp;
    private Jsd xsjsdFp;
    private FpDao fpDao;
    private XsjsdmxDao xsjsdmxDao;
    private Date CurrentTime = new Date();
    //分页组件 起始位置
    private int page;
    //分页组件 页面大小
    private int rows;
    //行索引
    private int index;
    //传入的企业机构Id值
    private Integer type;
    //结算单号
    private String jsdh;
    //客户的ID
    private Long glqyId;
    //发票类型ID
    private Long fpzlId;
    //客户的名称
    private String glqyQc;
    //公司的名称
    private String gsJc;
    //申请（查询）开始时间
    private Date sqrqStart;
    //申请（查询）结束时间
    private Date sqrqEnd;
    //销售结算单实体
    private Jsd fpcx;
    //销售结算单的ID
    private Long fpcxId;
    //申报人的Id
    private Long sprId;
    //申报人所在公司的Id
    private Long gsId;
    //状态
    private Integer shzt;
    //退回原因
    private String thyy;

    //发票张数
    private Long fpzs;
    //发票号码
    private String fphm;
    private Long xsjsdId;

    //功能操作
    private List<Gncz> gnczList;
    private GnczService gnczService;

    private File result = new File("result.txt");
    private FileWriter writer;

    private PrintWriter pw;

    private String fpze;

    private String kprq;

    //状态
    private Integer zt;


    //发票查询
    @Action("fpcxList")
    public void fpList() {
        Long ywgsID = YgService.getCurrentYgZgGsId();
        this.renderJson(this.fpcxService.findAllfpcx(type, zt, jsdh, sqrqStart, sqrqEnd, glqyId, glqyQc, gsId, gsJc, fpzlId, page, rows, ywgsID));
    }

    @Action("fpcx")
    public String fpcx() {
        gnczList = gnczService.findGnczByJsAndUrl(request.getServletPath());
        return SUCCESS;
    }


    @Action("fpcx_xsjsd_detail")
    public String fpcx_xsjsd_detail() {
        if (fpxsjsdId != null) {
            xsjsdFp = xsjsdService.findXsjsdDetail(fpxsjsdId);
        } else {
            xsjsdFp = new Jsd();
        }
        return SUCCESS;
    }

    //================================setter========getter=======================================


    public FpcxService getFpcxService() {
        return fpcxService;
    }

    public void setFpcxService(FpcxService fpcxService) {
        this.fpcxService = fpcxService;
    }

    public Long getFpcgjsdId() {
        return fpcgjsdId;
    }

    public void setFpcgjsdId(Long fpcgjsdId) {
        this.fpcgjsdId = fpcgjsdId;
    }

    public Long getFpwljsdId() {
        return fpwljsdId;
    }

    public void setFpwljsdId(Long fpwljsdId) {
        this.fpwljsdId = fpwljsdId;
    }

    public Long getFpxsjsdId() {
        return fpxsjsdId;
    }

    public void setFpxsjsdId(Long fpxsjsdId) {
        this.fpxsjsdId = fpxsjsdId;
    }

    public Jsd getXsjsdFp() {
        return xsjsdFp;
    }

    public void setXsjsdFp(Jsd xsjsdFp) {
        this.xsjsdFp = xsjsdFp;
    }

    public Jsd getWljsdFp() {
        return wljsdFp;
    }

    public void setWljsdFp(Jsd wljsdFp) {
        this.wljsdFp = wljsdFp;
    }

    public Jsd getCgjsdFp() {
        return cgjsdFp;
    }

    public void setCgjsdFp(Jsd cgjsdFp) {
        this.cgjsdFp = cgjsdFp;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public Date getCurrentTime() {
        return CurrentTime;
    }

    public void setCurrentTime(Date currentTime) {
        CurrentTime = currentTime;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getJsdh() {
        return jsdh;
    }

    public void setJsdh(String jsdh) {
        this.jsdh = jsdh;
    }

    public Long getGlqyId() {
        return glqyId;
    }

    public void setGlqyId(Long glqyId) {
        this.glqyId = glqyId;
    }

    public Long getFpzlId() {
        return fpzlId;
    }

    public void setFpzlId(Long fpzlId) {
        this.fpzlId = fpzlId;
    }

    public String getGlqyQc() {
        return glqyQc;
    }

    public void setGlqyQc(String glqyQc) {
        this.glqyQc = glqyQc;
    }

    public String getGsJc() {
        return gsJc;
    }

    public void setGsJc(String gsJc) {
        this.gsJc = gsJc;
    }

    public Date getSqrqStart() {
        return sqrqStart;
    }

    public void setSqrqStart(Date sqrqStart) {
        this.sqrqStart = sqrqStart;
    }

    public Date getSqrqEnd() {
        return sqrqEnd;
    }

    public void setSqrqEnd(Date sqrqEnd) {
        this.sqrqEnd = sqrqEnd;
    }

    public Jsd getFpcx() {
        return fpcx;
    }

    public void setFpcx(Jsd fpcx) {
        this.fpcx = fpcx;
    }

    public Long getFpcxId() {
        return fpcxId;
    }

    public void setFpcxId(Long fpcxId) {
        this.fpcxId = fpcxId;
    }

    public Long getSprId() {
        return sprId;
    }

    public void setSprId(Long sprId) {
        this.sprId = sprId;
    }

    public Integer getZt() {
        return zt;
    }

    public void setZt(Integer zt) {
        this.zt = zt;
    }

    public String getKprq() {
        return kprq;
    }

    public void setKprq(String kprq) {
        this.kprq = kprq;
    }

    public String getFpze() {
        return fpze;
    }

    public void setFpze(String fpze) {
        this.fpze = fpze;
    }

    public PrintWriter getPw() {
        return pw;
    }

    public void setPw(PrintWriter pw) {
        this.pw = pw;
    }

    public FileWriter getWriter() {
        return writer;
    }

    public void setWriter(FileWriter writer) {
        this.writer = writer;
    }

    public File getResult() {
        return result;
    }

    public void setResult(File result) {
        this.result = result;
    }

    public GnczService getGnczService() {
        return gnczService;
    }

    public void setGnczService(GnczService gnczService) {
        this.gnczService = gnczService;
    }

    public List<Gncz> getGnczList() {
        return gnczList;
    }

    public void setGnczList(List<Gncz> gnczList) {
        this.gnczList = gnczList;
    }

    public Long getXsjsdId() {
        return xsjsdId;
    }

    public void setXsjsdId(Long xsjsdId) {
        this.xsjsdId = xsjsdId;
    }

    public String getFphm() {
        return fphm;
    }

    public void setFphm(String fphm) {
        this.fphm = fphm;
    }

    public Long getFpzs() {
        return fpzs;
    }

    public void setFpzs(Long fpzs) {
        this.fpzs = fpzs;
    }

    public String getThyy() {
        return thyy;
    }

    public void setThyy(String thyy) {
        this.thyy = thyy;
    }

    public Integer getShzt() {
        return shzt;
    }

    public void setShzt(Integer shzt) {
        this.shzt = shzt;
    }

    public Long getGsId() {
        return gsId;
    }

    public void setGsId(Long gsId) {
        this.gsId = gsId;
    }

    @Autowired
    public void setXsjsdService(XsjsdService xsjsdService) {
        this.xsjsdService = xsjsdService;

    }

    @Autowired

    public void setFpDao(FpDao fpDao) {
        this.fpDao = fpDao;
    }

    @Autowired
    public void setXsjsdmxDao(XsjsdmxDao xsjsdmxDao) {
        this.xsjsdmxDao = xsjsdmxDao;
    }
}
